<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html;charset=UTF-8"
	import="com.srit.forecast.constant.Constant"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="srit-tag" uri="/srit-constant-tag"%>
<srit-tag:Constant var="PAGE_TYPE_FORM" />
<srit-tag:Constant var="PAGE_TYPE_LIST" />
<srit-tag:Constant var="PAGE_TYPE_ALL" />
<html>
<head>
<title></title>
<link href="<c:url value="/resources/css/style.css" />" rel="stylesheet"
	type="text/css">
<link href="<c:url value="/resources/css/list_css.css" />"
	rel="stylesheet" type="text/css">
<link href="<c:url value="/resources/css/autocomplete.css" />"
	rel="stylesheet" type="text/css">
<script src="<c:url value="/resources/js/jquery-1.8.0.min.js" />"></script>
</head>
<!-- 搜索 -->
<c:if test="${pageType==PAGE_TYPE_ALL}">
	<div id="SearchDiv"></div>
</c:if>

<!-- 列表页 -->
<c:if test="${pageType==PAGE_TYPE_LIST||pageType==PAGE_TYPE_ALL}">
	<div id="pageDiv">
		<table class="menu-pare" align='center' width="98%"
			style="text-align: right">
			<tr>
				<td><a href="<c:url  value="/effectTimeGroup-form"></c:url>">创建</a></td>
			</tr>
		</table>
		<table class="sritTable" align='center' id="table" width="98%"
			style="margin-top: 5px; text-align: center">
			<tr>
				<th><input type="checkbox" /></th>
				<th>ID</th>
				<th>NAME</th>
				<th>ORDERNO</th>
			</tr>
			<c:forEach var="bean" items="${page.list}">
				<tr onMouseOver="javascript:this.style.backgroundColor='#AABBFF';"
					onMouseOut="javascript:this.style.backgroundColor='#FFFFFF';"
					ondblclick="javascript:window.location='<c:url  value="/effectTimeGroup-edit">
					<c:param name="id" value="${bean.id }"/>
					</c:url>'">
					<td><input type="checkbox" value="${bean.id }" /></td>
					<td>${bean.id }</td>
					<td>${bean.name }</td>
					<td>${bean.orderNo }</td>
				</tr>
			</c:forEach>
		</table>

		<table class="sritTable" align='center' id="table" width="98%"
			style="margin-top: 0px">
			<tr>
				<td class="td_tl">${page.count},${page.pageNum}</td>
			</tr>
		</table>
	</div>
</c:if>

<c:if test="${pageType==PAGE_TYPE_FORM}">
	<div id="createDiv">
		<table class="menu-pare" align='center' width="98%"
			style="text-align: right">
			<tr>
				<td><a href="<c:url  value="/effectTimeGroup-search"></c:url>">返回</a></td>
			</tr>
		</table>
		<form:form action="/effectTimeGroup-saveOrUpdate"
			modelAttribute="effectTimeGroup" method="post">
			<form:hidden path="id" />
			<table class="sritTable" align='center' id="table" width="98%">
				<tr>
					<th colspan="4">时效组管理</th>
				</tr>
				<tr>
					<td class="td_tl">名称</td>
					<td><form:input path="name" /></td>
					<td class="td_tl">排序</td>
					<td><form:input path="orderNo" /></td>
				</tr>
				<tr>
					<td colspan="4" class="td_tl"><c:if
							test="${effectTimeGroup.id==null}">
							<input type="submit" value="保存" />
						</c:if> <c:if test="${effectTimeGroup.id!=null }">
							<input type="submit" value="修改" />
						</c:if> <input type="reset" /></td>
				</tr>
			</table>
		</form:form>
		<hr/>
		<table class="menu-son-form" align='center' width="98%"
			style="text-align: right">
			<tr>
				<td><a href="javascript:addSon()">新增</a></td>
			</tr>
		</table>
		<table class="sritTable listTable" align='center' width="98%"
			id="table-son-list">
			<tr>
				<th width="10%">ID</th>
				<th width="20%">时段</th>
				<th width="20%">间隔小时</th>
				<th width="20%">起始小时</th>
				<th width="20%">起始分钟</th>
			</tr>
			<c:forEach var="bean" items="${effectTimeGroup.effectTimeList}">
				<tr onMouseOver="javascript:this.style.backgroundColor='#AABBFF';"
					onMouseOut="javascript:this.style.backgroundColor='#FFFFFF';"
					ondblclick="javascript:modifyCode(${bean.id })">
					<td>${bean.id}</td>
					<td>${bean.section}</td>
					<td>${bean.interval}</td>
					<td>${bean.startHour}</td>
					<td>${bean.minutes}</td>
				</tr>
			</c:forEach>
		</table>
	
		<form:form modelAttribute="effectTimeListVo"
			action="/effectTime-saveList?groupId=${effectTimeGroup.id }"
			method="post">
			<table class="sritTable listTable" align='center' width="98%"
				id="table-son-form" style="visibility: hidden;">
				<tr class="tr_clone">
					<td width="10%"><input type="hidden" value="${effectTimeGroup.id}" />&nbsp;</td>
					<td width="20%"><input type="text"></td>
					<td width="20%"><input type="text"></td>
					<td width="20%"><input type="text"></td>
					<td width="20%"> <input type="text"></td>
				</tr>
				<tr>
					<td colspan="5" class="td_tl"><input type="submit" value="保存" />
					</td>
				</tr>
			</table>
		</form:form>
		
		<script>
			function addSon(){
				if ($("#table-son-form").css("visibility") == "visible") {
					var $clone = $(".tr_clone:last").clone();
					//$colone.attr("class","tr_colne")
					//console.log($clone)
					$(".tr_clone:last").after($clone);
				} else {
					$("#table-son-form").css("visibility", "visible");
				}
				changeRowAttribute();
			}
			
			function changeRowAttribute() {
				$.each($(".tr_clone"), function(i, el) {
					//console.log(el)
					//console.log(i)
					$.each($(el).find("td"), function(j, elson) {
						var list = "effectTimeList[" + i + "]"
						switch (j) {
						case 0:
							$(elson).children().attr("name", list + ".groupId");
							break;
						case 1:
							$(elson).children().attr("name", list + ".section");
							break;
						case 2:
							$(elson).children().attr("name", list + ".interval");
							break;
						case 3:
							$(elson).children().attr("name", list + ".startHour");
							break;
						case 4:
							$(elson).children().attr("name", list + ".minutes");
							break;
						default:
							return
						}
					})
				});
			}
			
		</script>
		

	</div>
</c:if>




</html>




